From: Florian Müllner Date: Tue, 16 Jun 2020 20:53:37 +0000 (+0200) Subject: st/viewport: Fix horizontal translation in RTL locales X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~684^2^2~241 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3f4b253dacba460ee359bc832dfbbe40022734aa;p=gnome-shell.git st/viewport: Fix horizontal translation in RTL locales In RTL locales, the lowest value should correspond to the right-most position and vice-versa. That this went unnoticed for so long shows how we have avoided horizontal scrolling so far :-) https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1318 --- diff --git a/src/st/st-viewport.c b/src/st/st-viewport.c index 0eb5a22a1..fb1df91d9 100644 --- a/src/st/st-viewport.c +++ b/src/st/st-viewport.c @@ -301,6 +301,26 @@ st_viewport_allocate (ClutterActor *actor, } } +static double +get_hadjustment_value (StViewport *viewport) +{ + StViewportPrivate *priv = st_viewport_get_instance_private (viewport); + ClutterTextDirection direction; + double x, upper, page_size; + + if (!priv->hadjustment) + return 0; + + st_adjustment_get_values (priv->hadjustment, + &x, NULL, &upper, NULL, NULL, &page_size); + + direction = clutter_actor_get_text_direction (CLUTTER_ACTOR (viewport)); + if (direction == CLUTTER_TEXT_DIRECTION_RTL) + return upper - page_size - x; + + return x; +} + static void st_viewport_apply_transform (ClutterActor *actor, CoglMatrix *matrix) @@ -314,7 +334,7 @@ st_viewport_apply_transform (ClutterActor *actor, parent_class->apply_transform (actor, matrix); if (priv->hadjustment) - x = st_adjustment_get_value (priv->hadjustment); + x = get_hadjustment_value (viewport); else x = 0; @@ -336,7 +356,7 @@ get_border_paint_offsets (StViewport *viewport, StViewportPrivate *priv = st_viewport_get_instance_private (viewport); if (priv->hadjustment) - *x = st_adjustment_get_value (priv->hadjustment); + *x = get_hadjustment_value (viewport); else *x = 0;